<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/icon.css">
<link rel="stylesheet" href="static/css/style.css" />
<script src="static/jquery/jquery-1.12.4.js"></script>
<script src="static/easyui/jquery.easyui.min.js"></script>
<script src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>主预算</title>
</head>

<body>
	<div class="content-container" data-options="region:'center'" title="主预算列表">
	<div class="panel-header"><div class="panel-title">主预算列表</div></div>
		<table id="pro_table" class="easyui-datagrid" style="height: 100%">
		</table>
	</div>
</body>
<script th:inline="javascript">
	var currentPro;
	var projectitemid = [[${projectitemid}]];
	
	$(document).ready(function() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			url : "tomainbudget.do?projectitemid="+projectitemid,
			method : 'get',
			onSelect : function(index, row) {
				currentPro = row;
			},
			columns : [ [ {
				field : 'title',
				title : '项目名',
				width : '',
				formatter : function(value,row,index){
					if(row.projectitemchild){
						return row.projectitemchild.name;
					}else{
						return row.item.name;
					}
				}
			}, {
				field : 'money',
				title : '已审金额',
				width : ''
			}, {
				field : 'money2',
				title : '待审金额',
				width : '',
				formatter : function(value, row, index) {
					var sum = 0;
					$.each(row.subitems,function(i,val){
						if(val.status==6||val.status==7){
							sum+=parseFloat(val.money);
						}
					});
					return sum;
					
				}
			}, {
				field : 'handle',
				title : '操作',
				width : '',
				formatter : function(value, row, index) {
					return '<a style="color:blue" href="#" onclick="addTab('+index+')">查看预算明细</a>';
				}
			} ] ]
		});
	});
	
	function addTab(index) {
		var item = $("#pro_table").datagrid('getRows')[index];
		var title = '预算明细-'+item.item.name;
		window.parent.window.addTab(title,"tobudgetsubitem.do?budgetmainid="+item.id,item.id);
	}
	
</script>

</html>